XF.Check = new function() {
	this.DefaultSiteId = null;
	
	this.init = function(){
		_init_workDay_Select();
		//_init_schedule_workDay_Select();
		_init_schedule();
	};
	
	/*请假相关JS*/
	this.addLeave = function() {
		XF.lightSideBar('addLeave');
		var url  = global.contextPath + "/check/addLeave"
		$.ajax({
		  url: url,
		  type: "post",
		  data: {},
		  complete: function(xhr){
			  xhr = xhr['responseText'];
			  $("#checkCenter").html(xhr);
		  }
		});		
	};
	this.editLeave = function(id) {
		$.ajax({
			type:'post',
			url:global.contextPath + "/check/editLeave",
			data:{id:id},
			complete:function(xhr){
				xhr = xhr['responseText'];
				$('#checkCenter').html(xhr);
			}
		});
	};
	
	this.editPersonLeave = function(id) {
		$.ajax({
			type:'post',
			url:global.contextPath + "/check/editPersonLeave",
			data:{id:id},
			complete:function(xhr){
				xhr = xhr['responseText'];
				$('#checkCenter').html(xhr);
			}
		});
	};
	
	this.deleteLeave = function(id){
		$.messager.confirm('提示',"确认删除这条记录？",function(r){
		    if (r){
				var url  = global.contextPath + "/check/deleteLeave"
				$.ajax({
				  url: url,
				  type: "post",
				  data: {id:id},
				  complete: function(xhr){
					  xhr = xhr['responseText'];
					  xhr = new Function("return " + xhr);
					  xhr = xhr();
					  xhr = xhr['status'];
					  if(xhr=="SUCCESS"){
						  $.messager.show({
							title:'提示',
							msg:'删除成功',
							timeout:3000,
							showType:'slide'
						  });
						  $(".userListWrap tr i[s="+id+"]").parent().parent().parent().remove();
					  }else if(xhr=="FAILD"){
						  $.messager.show({
							title:'提示',
							msg:'删除失败',
							timeout:5000,
							showType:'slide'
						  });
					  }
				   }
				});
		    }
		});
	};
	
	this.addPersonLeave = function() {
		XF.lightSideBar('addPersonLeave');
		var url  = global.contextPath + "/check/addPersonLeave"
		$.ajax({
		  url: url,
		  type: "post",
		  data: {},
		  complete: function(xhr){
			  xhr = xhr['responseText'];
			  $("#checkCenter").html(xhr);
		  }
		});		
	};
	
	this.doAddPersonLeave = function(leaveJson,year_month,siteid) {		
		$.ajax({
			type:'post',
			url:global.contextPath + "/check/doAddPersonLeave",
			dataType: 'json',
			data:{leaveJson:leaveJson},
			success:function(result){
				if (result.status == 'SUCCESS') {
					$.messager.show({
						showType:'fade',
						msg:"操作成功",
						title:"提示",
						timeout:"3000"
					});
					XF.Check.leavePersonList(year_month,siteid);
				} else {
					$.messager.show({
						showType:'fade',
						msg:"操作失败："+result.msg,
						title:"提示",
						timeout:"3000"
					});
				}
			}			
		});
	}
	
	this.userDestroyLeave = function(id){
		$.messager.confirm('提示',"确认申请销毁这条记录？",function(r){
			if(r){
				$.ajax({
					type:'post',
					url:global.contextPath + "/check/userDestroyLeave",
					data:{id:id},
					complete:function(xhr){
						xhr = xhr['responseText'];
						$('#checkCenter').html(xhr);
					}
				});
			}
		})		
	}
	
	
	this.userDelLeave = function(id){
		$.messager.confirm('提示',"确认申请删除这条记录？",function(r){
		    if (r){
				var url  = global.contextPath + "/check/userDelLeave"
				$.ajax({
				  url: url,
				  type: "post",
				  data: {id:id},
				  complete: function(xhr){
					  xhr = xhr['responseText'];
					  xhr = new Function("return " + xhr);
					  xhr = xhr();
					  xhr = xhr['status'];
					  if(xhr=="SUCCESS"){
						  $.messager.show({
							title:'提示',
							msg:'申请删除成功',
							timeout:3000,
							showType:'slide'
						  });
						  $("#s"+id+"" ).replaceWith("<span>已申请删除</span>");
					  }else if(xhr=="FAILD"){
						  $.messager.show({
							title:'提示',
							msg:'删除失败',
							timeout:5000,
							showType:'slide'
						  });
					  }
				   }
				});
		    }
		});
	};
	
	this.deptDelLeave = function(id){
		var url  = global.contextPath + "/check/deptDelLeave"
		$.ajax({
		  url: url,
		  type: "post",
		  data: {id:id},
		  complete: function(xhr){
			  xhr = xhr['responseText'];
			  xhr = new Function("return " + xhr);
			  xhr = xhr();
			  xhr = xhr['status'];
			  if(xhr=="SUCCESS"){
				  $.messager.show({
					title:'提示',
					msg:'操作成功',
					timeout:3000,
					showType:'slide'
				  });
				  $("#s"+id+"" ).replaceWith("<span>已同意删除</span>");
			  }else if(xhr=="FAILD"){
				  $.messager.show({
					title:'提示',
					msg:'删除失败',
					timeout:5000,
					showType:'slide'
				  });
			  }
		   }
		});
	};
	
	this.deptDelMend = function(id){
		var url  = global.contextPath + "/check/deptDelMend"
		$.ajax({
		  url: url,
		  type: "post",
		  data: {id:id},
		  complete: function(xhr){
			  xhr = xhr['responseText'];
			  xhr = new Function("return " + xhr);
			  xhr = xhr();
			  xhr = xhr['status'];
			  if(xhr=="SUCCESS"){
				  $.messager.show({
					title:'提示',
					msg:'操作成功',
					timeout:3000,
					showType:'slide'
				  });
				  $("#s"+id+"" ).replaceWith("<span>已同意删除</span>");
			  }else if(xhr=="FAILD"){
				  $.messager.show({
					title:'提示',
					msg:'删除失败',
					timeout:5000,
					showType:'slide'
				  });
			  }
		   }
		});
	};
		
	
	
	this.noDeptLeave = function(id){		
		$.messager.confirm('提示',"确认不通过这条记录？",function(r){
			if(r){
				$.ajax({
					type:'post',
					url:global.contextPath + "/check/noDeptLeave",
					data:{id:id},
					complete:function(xhr){
						xhr = xhr['responseText'];
						$('#checkCenter').html(xhr);
					}
				});
			}			
		})
		
	}
	
	this.noPersonLeave = function(id){		
		$.messager.confirm('提示',"确认不通过这条记录？",function(r){
			if(r){
				$.ajax({
					type:'post',
					url:global.contextPath + "/check/noPersonLeave",
					data:{id:id},
					complete:function(xhr){
						xhr = xhr['responseText'];
						$('#checkCenter').html(xhr);
					}
				});
			}			
		})
		
	}
	
	this.auditDeptLeave = function(id,username) {
		$.messager.confirm('提示',"确认通过这条记录？",function(r){
		    if (r){
				var url  = global.contextPath + "/check/auditDeptLeave"
				$.ajax({
				  url: url,
				  type: "post",
				  data: {id:id,deptuser:username},
				  complete: function(xhr){
					  xhr = xhr['responseText'];
					  xhr = new Function("return " + xhr);
					  xhr = xhr();
					  xhr = xhr['status'];
					  if(xhr=="SUCCESS"){
						  $.messager.show({
							title:'提示',
							msg:'通过成功',
							timeout:3000,
							showType:'slide'
						  });
						$("#a"+id+"" ).replaceWith("<span>已审核通过</span>");
						$("#n"+id+"" ).remove();
					  }
				   }
				});
		    }
		});
	}
	
	this.auditPersonLeave = function(id,personflag,s) {
		$.messager.confirm('提示',"确认通过这条记录？",function(r){
		    if (r){
				var url  = global.contextPath + "/check/auditPersonLeave"
				$.ajax({
				  url: url,
				  type: "post",
				  data: {id:id,personflag:personflag},
				  complete: function(xhr){
					  xhr = xhr['responseText'];
					  xhr = new Function("return " + xhr);
					  xhr = xhr();
					  xhr = xhr['status'];
					  if(xhr=="SUCCESS"){
						  $.messager.show({
							title:'提示',
							msg:'操作成功',
							timeout:3000,
							showType:'slide'
						  });
						if(s == 'd'){
							$("#e"+id+"" ).remove();
							$("#d"+id+"" ).remove();
							$("#p"+id+"" ).replaceWith("<span id='span"+id+"' class='inLink'>已审核通过</span><a class='inLink' id='cp"+id+"' href='javascript:XF.Check.auditPersonLeave("+id+",0,\"cp\")'>反审核</a>");
						}else if(s == 'p'){
							$("#n"+id+"" ).remove();
							$("#a"+id+"" ).replaceWith("<span id='span"+id+"' class='inLink'>已审核通过</span><a class='inLink' id='cdp"+id+"' href='javascript:XF.Check.auditPersonLeave("+id+",4,\"cdp\")'>反审核</a>");
						}else if(s == 'cdp'){
							var cdp = "<a class='inLink' id='a"+id+"' href='javascript:XF.Check.auditPersonLeave("+id+",2,\"p\")'>审核通过</a>"
								cdp+= "<a class='inLink' id='n"+id+"' href='javascript:XF.Check.noPersonLeave("+id+")'>不通过</a>"
							$("#cdp"+id+"" ).remove();
							$("#span"+id+"" ).replaceWith(cdp);
						}else if(s == 'cp'){
							var cp = "<a class='inLink' id='e"+id+"' href='javascript:XF.Check.editPersonLeave("+id+")'>修改</a>";
								cp+= "<a class='inLink' id='d"+id+"' href='javascript:XF.Check.deleteLeave("+id+")'>删除</a>";
								cp+= "<a class='inLink' id='p"+id+"' href='javascript:XF.Check.auditPersonLeave("+id+",2,\"d\")'>审核</a>";
							$("#cp"+id+"" ).remove();
							$("#span"+id+"" ).replaceWith(cp);
						}
					  }
				   }
				});
		    }
		});
	}
	
	this.deptDestroyLeave = function(id,username){
		$.messager.confirm('提示',"确认同意销毁这条记录？",function(r){
		    if (r){
				var url  = global.contextPath + "/check/deptDestroyLeave"
				$.ajax({
				  url: url,
				  type: "post",
				  data: {id:id,deptuser:username},
				  complete: function(xhr){
					  xhr = xhr['responseText'];
					  xhr = new Function("return " + xhr);
					  xhr = xhr();
					  xhr = xhr['status'];
					  if(xhr=="SUCCESS"){
						  $.messager.show({
							title:'提示',
							msg:'同意销毁成功',
							timeout:3000,
							showType:'slide'
						  });
						$("#d"+id+"" ).replaceWith("<span>已同意销毁</span>");	

					  }
				   }
				});
		    }
		});
	}
	
	this.personDestroyLeave = function(id){
		$.messager.confirm('提示',"确认同意销毁这条记录？",function(r){
		    if (r){
				var url  = global.contextPath + "/check/personDestroyLeave"
				$.ajax({
				  url: url,
				  type: "post",
				  data: {id:id},
				  complete: function(xhr){
					  xhr = xhr['responseText'];
					  xhr = new Function("return " + xhr);
					  xhr = xhr();
					  xhr = xhr['status'];
					  if(xhr=="SUCCESS"){
						  $.messager.show({
							title:'提示',
							msg:'同意销毁成功',
							timeout:3000,
							showType:'slide'
						  });
						$("#d"+id+"" ).replaceWith("<span>已同意销毁</span>");	

					  }
				   }
				});
		    }
		});
	}
	
	this.leaveList = function(year_month,userid) {		
		XF.lightSideBar('leaveList');
		_leave_search(year_month,null,userid,null);			
	};
	
	this.leaveDeptList = function(year_month,siteid,deptid) {		
		XF.lightSideBar('leaveDeptList');
		_leave_search(year_month,siteid,null,deptid);
	};
	
	this.leavePersonList = function(year_month,siteid) {
		XF.lightSideBar('leavePersonList');
		_leave_person_search(year_month,siteid,null,null);
	};
	
	this.leaveListSearch = function() {
		var year_month = $("#year_month").val();
		var userid = $("input[name=userid]").val();
		var siteid = "";
		var deptid = "";
		_leave_search(year_month,siteid,userid,deptid);
	}
	this.deptLeaveListSearch = function() {
		var year_month = $("#year_month").val();
		var userid = $("input[name=userid]").val();
		var siteid = $("input[name=siteid]").val();
		var deptid = $("input[name=deptid]").val();
		_leave_search(year_month,siteid,userid,deptid);
	}
	
	this.personLeaveListSearch = function() {
		var year_month = $("#year_month").val();
		var userid = $("input[name=userid]").val();
		var siteid = $("#siteList").combobox('getValue');
		var deptid = $("#deptList").combobox('getValue');
		_leave_person_search(year_month,siteid,userid,deptid);
	}
	
	function _leave_search(year_month,siteid, userid, deptid){
		config.leave_search['args'] = [year_month,siteid, userid, deptid];
        SMT.xconfig.gvar.pageNum = '1';
        SMT.ajax(config.leave_search);
	}
	
	function _leave_person_search(year_month,siteid, userid, deptid){
		config.leave_person_search['args'] = [year_month,siteid, userid, deptid];
        SMT.xconfig.gvar.pageNum = '1';
        SMT.ajax(config.leave_person_search);
	}
	
	
	
	this.checkExport = function() {
		var year_month = $("#year_month").val();
		if(year_month == ""){
			alert("导出原始考勤要选择年月");
		}else{
			var userid = $("#userid").val();
			var siteid = $("#siteid").combobox('getValues');
			var sitename = $("#siteid").combobox('getText');				
			var deptid=$('#deptid').combobox('getValue');
			var deptname=$('#deptid').combobox('getText');			
			var url = global.contextPath+"/check/checkExport?year_month="+year_month+"&siteid="+siteid
					+"&sitename="+sitename+"&deptid="+deptid+"&deptname="+deptname+"&userid="+userid;
			window.open(url);
		}
		
	}
	
	
	/**补卡相关js***************************/
	this.addMend = function() {
		XF.lightSideBar('addMend');
		var url  = global.contextPath + "/check/addMend"
		$.ajax({
		  url: url,
		  type: "post",
		  data: {},
		  complete: function(xhr){
			  xhr = xhr['responseText'];
			  $("#checkCenter").html(xhr);
		  }
		});		
	};
	
	this.editMend = function(id) {
		$.ajax({
			type:'post',
			url:global.contextPath + "/check/editMend",
			data:{id:id},
			complete:function(xhr){
				xhr = xhr['responseText'];
				$('#checkCenter').html(xhr);
			}
		});
	};
	
	this.editPersonMend = function(id) {
		$.ajax({
			type:'post',
			url:global.contextPath + "/check/editPersonMend",
			data:{id:id},
			complete:function(xhr){
				xhr = xhr['responseText'];
				$('#checkCenter').html(xhr);
			}
		});
	};
	
	this.deleteMend = function(id){
		$.messager.confirm('提示',"确认删除这条记录？",function(r){
		    if (r){
				var url  = global.contextPath + "/check/deleteMend"
				$.ajax({
				  url: url,
				  type: "post",
				  data: {id:id},
				  complete: function(xhr){
					  xhr = xhr['responseText'];
					  xhr = new Function("return " + xhr);
					  xhr = xhr();
					  xhr = xhr['status'];
					  if(xhr=="SUCCESS"){
						  $.messager.show({
							title:'提示',
							msg:'删除成功',
							timeout:3000,
							showType:'slide'
						  });
						  $(".userListWrap tr i[s="+id+"]").parent().parent().parent().remove();
					  }else if(xhr=="FAILD"){
						  $.messager.show({
							title:'提示',
							msg:'删除失败',
							timeout:5000,
							showType:'slide'
						  });
					  }
				   }
				});
		    }
		});
	};
	
	this.addPersonMend = function() {
		XF.lightSideBar('addPersonMend');
		var url  = global.contextPath + "/check/addPersonMend"
		$.ajax({
		  url: url,
		  type: "post",
		  data: {},
		  complete: function(xhr){
			  xhr = xhr['responseText'];
			  $("#checkCenter").html(xhr);
		  }
		});		
	};
	
	this.doAddPersonMend = function(mendJson,year_month,siteid) {		
		$.ajax({
			type:'post',
			url:global.contextPath + "/check/doAddPersonMend",
			dataType: 'json',
			data:{mendJson:mendJson},
			success:function(result){
				if (result.status == 'SUCCESS') {
					$.messager.show({
						showType:'fade',
						msg:"操作成功",
						title:"提示",
						timeout:"3000"
					});
					XF.Check.mendPersonList(year_month,siteid);
				} else {
					$.messager.show({
						showType:'fade',
						msg:"操作失败："+result.msg,
						title:"提示",
						timeout:"3000"
					});
				}
			}			
		});
	}
	
	this.userDestroyMend = function(id){
		$.messager.confirm('提示',"确认申请销毁这条记录？",function(r){
			if(r){
				$.ajax({
					type:'post',
					url:global.contextPath + "/check/userDestroyMend",
					data:{id:id},
					complete:function(xhr){
						xhr = xhr['responseText'];
						$('#checkCenter').html(xhr);
					}
				})
			}
		});
	}
	this.userDelMend = function(id){
		$.messager.confirm('提示',"确认申请删除这条记录？",function(r){
		    if (r){
				var url  = global.contextPath + "/check/userDelMend"
				$.ajax({
				  url: url,
				  type: "post",
				  data: {id:id},
				  complete: function(xhr){
					  xhr = xhr['responseText'];
					  xhr = new Function("return " + xhr);
					  xhr = xhr();
					  xhr = xhr['status'];
					  if(xhr=="SUCCESS"){
						  $.messager.show({
							title:'提示',
							msg:'申请删除成功',
							timeout:3000,
							showType:'slide'
						  });
						  $("#s"+id+"" ).replaceWith("<span>已申请删除</span>");
					  }else if(xhr=="FAILD"){
						  $.messager.show({
							title:'提示',
							msg:'删除失败',
							timeout:5000,
							showType:'slide'
						  });
					  }
				   }
				});
		    }
		});
	};
	
	this.noDeptMend = function(id){		
		$.messager.confirm('提示',"确认不通过这条记录？",function(r){
			if(r){
				$.ajax({
					type:'post',
					url:global.contextPath + "/check/noDeptMend",
					data:{id:id},
					complete:function(xhr){
						xhr = xhr['responseText'];
						$('#checkCenter').html(xhr);
					}
				});
			}			
		})
		
	}
	
	this.noPersonMend = function(id){		
		$.messager.confirm('提示',"确认不通过这条记录？",function(r){
			if(r){
				$.ajax({
					type:'post',
					url:global.contextPath + "/check/noPersonMend",
					data:{id:id},
					complete:function(xhr){
						xhr = xhr['responseText'];
						$('#checkCenter').html(xhr);
					}
				});
			}			
		})
		
	}
	
	this.auditDeptMend = function(id,username) {
		$.messager.confirm('提示',"确认通过这条记录？",function(r){
		    if (r){
				var url  = global.contextPath + "/check/auditDeptMend"
				$.ajax({
				  url: url,
				  type: "post",
				  data: {id:id,deptuser:username},
				  complete: function(xhr){
					  xhr = xhr['responseText'];
					  xhr = new Function("return " + xhr);
					  xhr = xhr();
					  xhr = xhr['status'];
					  if(xhr=="SUCCESS"){
						  $.messager.show({
							title:'提示',
							msg:'通过成功',
							timeout:3000,
							showType:'slide'
						  });
						$("#a"+id+"" ).replaceWith("<span>已审核通过</span>");
						$("#n"+id+"" ).remove();
					  }
				   }
				});
		    }
		});
	}
	
	this.auditPersonMend = function(id,personflag,s) {
		$.messager.confirm('提示',"确认通过这条记录？",function(r){
		    if (r){
				var url  = global.contextPath + "/check/auditPersonMend"
				$.ajax({
				  url: url,
				  type: "post",
				  data: {id:id,personflag:personflag},
				  complete: function(xhr){
					  xhr = xhr['responseText'];
					  xhr = new Function("return " + xhr);
					  xhr = xhr();
					  xhr = xhr['status'];
					  if(xhr=="SUCCESS"){
						  $.messager.show({
							title:'提示',
							msg:'通过成功',
							timeout:3000,
							showType:'slide'
						  });
						if(s == 'd'){
							$("#e"+id+"" ).remove();
							$("#d"+id+"" ).remove();
							$("#p"+id+"" ).replaceWith("<span id='span"+id+"' class='inLink'>已审核通过</span><a class='inLink' id='cp"+id+"' href='javascript:XF.Check.auditPersonMend("+id+",0,\"cp\")'>反审核</a>");
						}else if(s == 'p'){
							$("#n"+id+"" ).remove();
							$("#a"+id+"" ).replaceWith("<span id='span"+id+"' class='inLink'>已审核通过</span><a class='inLink' id='cdp"+id+"' href='javascript:XF.Check.auditPersonMend("+id+",4,\"cdp\")'>反审核</a>");
						}else if(s == 'cdp'){
							var cdp = "<a class='inLink' id='a"+id+"' href='javascript:XF.Check.auditPersonMend("+id+",2,\"p\")'>审核通过</a>"
							cdp+= "<a class='inLink' id='n"+id+"' href='javascript:XF.Check.noPersonMend("+id+")'>不通过</a>"
							$("#cdp"+id+"" ).remove();
							$("#span"+id+"" ).replaceWith(cdp);
						}else if(s == 'cp'){
							var cp = "<a class='inLink' id='e"+id+"' href='javascript:XF.Check.editPersonMend("+id+")'>修改</a>";
								cp+= "<a class='inLink' id='d"+id+"' href='javascript:XF.Check.deleteMend("+id+")'>删除</a>";
								cp+= "<a class='inLink' id='p"+id+"' href='javascript:XF.Check.auditPersonMend("+id+",2,\"d\")'>审核</a>";
							$("#cp"+id+"" ).remove();
							$("#span"+id+"" ).replaceWith(cp);
						}
						
					  }
				   }
				});
		    }
		});
	}
	
	this.deptDestroyMend = function(id,username){
		$.messager.confirm('提示',"确认同意销毁这条记录？",function(r){
		    if (r){
				var url  = global.contextPath + "/check/deptDestroyMend"
				$.ajax({
				  url: url,
				  type: "post",
				  data: {id:id,deptuser:username},
				  complete: function(xhr){
					  xhr = xhr['responseText'];
					  xhr = new Function("return " + xhr);
					  xhr = xhr();
					  xhr = xhr['status'];
					  if(xhr=="SUCCESS"){
						  $.messager.show({
							title:'提示',
							msg:'同意销毁成功',
							timeout:3000,
							showType:'slide'
						  });
						$("#d"+id+"" ).replaceWith("<span>已同意销毁</span>");	

					  }
				   }
				});
		    }
		});
	}
	
	this.personDestroyMend = function(id){
		$.messager.confirm('提示',"确认同意销毁这条记录？",function(r){
		    if (r){
				var url  = global.contextPath + "/check/personDestroyMend"
				$.ajax({
				  url: url,
				  type: "post",
				  data: {id:id},
				  complete: function(xhr){
					  xhr = xhr['responseText'];
					  xhr = new Function("return " + xhr);
					  xhr = xhr();
					  xhr = xhr['status'];
					  if(xhr=="SUCCESS"){
						  $.messager.show({
							title:'提示',
							msg:'同意销毁成功',
							timeout:3000,
							showType:'slide'
						  });
						$("#d"+id+"" ).replaceWith("<span>已同意销毁</span>");	

					  }
				   }
				});
		    }
		});
	}
	
	this.mendPersonList = function(year_month,siteid) {			
		XF.lightSideBar('mendPersonList');
		_mend_person_search(year_month,siteid,null,null);			
	};
	
	this.mendList = function(year_month,userid) {	
		XF.lightSideBar('mendList');
		_mend_search(year_month,null,userid,null);			
	};
	
	this.mendDeptList = function(year_month,siteid,deptid) {		
		XF.lightSideBar('mendDeptList');
		_mend_search(year_month,siteid,null,deptid);			
	};
	
	this.mendListSearch = function() {
		var year_month = $("#year_month").val();
		var userid = $("input[name=userid]").val();
		var siteid = "";
		var deptid = "";
		_mend_search(year_month,siteid,userid,deptid);
	}
	this.deptMendListSearch = function() {
		var year_month = $("#year_month").val();
		var userid = $("input[name=userid]").val();
		var siteid = $("input[name=siteid]").val();
		var deptid = $("input[name=deptid]").val();
		_mend_search(year_month,siteid,userid,deptid);
	}
	
	this.personMendListSearch = function() {
		var year_month = $("#year_month").val();
		var userid = $("input[name=userid]").val();
		var siteid = $("#siteList").combobox('getValue');
		var deptid = $("#deptList").combobox('getValue');
		_mend_person_search(year_month,siteid,userid,deptid);
	}
	
	function _mend_search(year_month,siteid, userid, deptid){
		config.mend_search['args'] = [year_month,siteid, userid, deptid];
        SMT.xconfig.gvar.pageNum = '1';
        SMT.ajax(config.mend_search);
	}
	
	function _mend_person_search(year_month,siteid, userid, deptid){
		config.mend_person_search['args'] = [year_month,siteid, userid, deptid];
        SMT.xconfig.gvar.pageNum = '1';
        SMT.ajax(config.mend_person_search);
	}
	
	
	

	
	this.addHoliday = function() {
		XF.lightSideBar('addHoliday');
		var url  = global.contextPath + "/check/addHoliday"
		$.ajax({
		  url: url,
		  type: "post",
		  data: {},
		  complete: function(xhr){
			  xhr = xhr['responseText'];
			  $("#checkCenter").html(xhr);
		  }
		});		
	};

	this.holidayList = function() {
		XF.lightSideBar('holidayList');
		_holiday_search(null,null,null);
	};
	
	this.holidayListSearch = function() {
		var siteid = $("#siteList").combobox('getValue');
		_holiday_search(siteid);
	}
	
	this.deleteHoliday = function(id) {
		$.messager.confirm('操作提示','确定删除这条记录吗',function(data){
			if(data){
				$.ajax({
					url:""+global.contextPath+"/check/deleteHoliday",
					type:"post",
					data:"id="+id,
					success:function(data){
						$.messager.show({
							title:'提示',
							msg:'删除成功',
							timeout:3000,
							showType:'slide'
						});
						XF.Check.holidayListSearch();
					}
				});
			}
		});		
	}

	this.editHoliday = function(id) {
		$.ajax({
			type:'post',
			url:global.contextPath + "/check/editHoliday",
			data:{id:id},
			complete:function(xhr){
				xhr = xhr['responseText'];
				$('#checkCenter').html(xhr);
			}
		});
	}
	
	function _holiday_search(siteid){
		config.holiday_search['args'] = [siteid];
        SMT.xconfig.gvar.pageNum = '1';
        SMT.ajax(config.holiday_search);
	}
	
	
	this.addData = function() {
		XF.lightSideBar('addData');
		$.ajax({
			type:'post',
			url:global.contextPath + "/check/addData",
			complete:function(xhr){
				xhr = xhr['responseText'];
				$('#checkCenter').html(xhr);
			}
		});
	}
	
	this.dataList = function(defaultSiteId) {
		var siteid = null;
		if(typeof(defaultSiteId)!='undefined'){
			siteid = defaultSiteId;
		}
		XF.lightSideBar('dataList');
		_data_search(null,siteid,null,null);
	};
	
	this.checkSitesReportList = function(siteid,date) {
		XF.lightSideBar('checkSitesReportList');
		_checkSitesReportListSearch_search(siteid,date);
	};
	
	function _checkSitesReportListSearch_search(siteid,date){
		config.checkSitesReportList_search['args'] = [siteid,date];
        SMT.xconfig.gvar.pageNum = '1';
        SMT.ajax(config.checkSitesReportList_search);
	}
	
	this.checkSitesReportListSearch = function() {
		var year_month = $("#year_month").val();
		var siteid = $("#siteid").combobox('getValue');
		_checkSitesReportListSearch_search(siteid,year_month);
	}
	
	this.checkDatailReportList = function(defaultSiteId,defdeptid,year_month) {
		var siteid = null;
		var deptid = null;
		if(typeof(defaultSiteId)!='undefined'){
			siteid = defaultSiteId;
		}
		if(typeof(defdeptid)!='undefined'){
			deptid = defdeptid;
		}
		XF.lightSideBar('checkDatailReportList');
		_checkDatailReportListSearch_search(year_month,siteid,deptid,null)
		
        
	};
	this.checkDatailReportListSearch = function() {
		var sites = $("#siteid").combobox('getValues');
		var siteid="";
		var s="";
		for (var i = 0; i < sites.length; i++) {
			siteid +=s+sites[i];
			if(sites.length>1){
				s=",";
			}
		}
		var deptid = "";
		if(sites.length<2){
			deptid = $("#deptid").combobox('getValue');
		}
		var year_month = $("#year_month").val();
		_checkDatailReportListSearch_search(year_month,siteid,deptid,null);
	}
	function _checkDatailReportListSearch_search(year_month,siteid,deptid,userid){
		config.checkDatailReportList_search['args'] = [year_month,siteid,deptid,userid];
        SMT.xconfig.gvar.pageNum = '1';
        SMT.ajax(config.checkDatailReportList_search);
	}
	
	this.dataListSearch = function() {
		var userid = $("#userid").val();
		var sites = $("#siteid").combobox('getValues');
		var siteid="";
		var s="";
		for (var i = 0; i < sites.length; i++) {
			siteid +=s+sites[i];
			if(sites.length>1){
				s=",";
			}
		}
		var deptid = "";
		if(sites.length<2){
			deptid = $("#deptid").combobox('getValue');
		}
		var year_month = $("#year_month").val();
		_data_search(year_month,siteid,deptid,userid);
	}

	function _data_search(year_month,siteid,deptid,userid){
		config.data_search['args'] = [year_month,siteid,deptid,userid];
        SMT.xconfig.gvar.pageNum = '1';
        SMT.ajax(config.data_search);
	}
	//------班次设置
	this.shiftList = function(defaultSiteId) {
		var siteId = null;
		if(typeof(defaultSiteId)!='undefined'){
			siteId = defaultSiteId;
		}
		XF.lightSideBar('shiftList');
		_shift_search(siteId,null,null);
	};
	
	this.shiftListSearch = function(){
		var siteid = $("#siteList").combobox('getValue');
		_shift_search(siteid,null);
	};
	
	this.addShift = function() {
		XF.lightSideBar('addShift');
		var url  = global.contextPath + "/check/addShift";
		$.ajax({
		  url: url,
		  type: "post",
		  data: {},
		  complete: function(xhr){
			  xhr = xhr['responseText'];
			  $("#checkCenter").html(xhr);
		  }
		});		
	};
	
	this.deleteShift = function(id) {
		$.messager.confirm('操作提示','确定删除这条记录吗',function(data){
			if(data){
				$.ajax({
					url:""+global.contextPath+"/check/deleteShift",
					type:"post",
					data:"id="+id,
					success:function(data){
						$.messager.show({
							title:'提示',
							msg:'删除成功',
							timeout:3000,
							showType:'slide'
						});
						XF.Check.shiftListSearch();
					}
				});
			}
		});		
	}
	
	this.editShift = function(id) {
		$.ajax({
			type:'post',
			url:global.contextPath + "/check/editShift",
			data:{id:id},
			complete:function(xhr){
				xhr = xhr['responseText'];
				$('#checkCenter').html(xhr);
			}
		});
	}
	
	this.setShift = function(o){
		if("f"==o){
			$('#fCheckintime_hour').combobox('setValue', '08');
			$('#fCheckintime_minute').combobox('setValue', '30');
			$('#fCheckouttime_hour').combobox('setValue', '12');
			$('#fCheckouttime_minute').combobox('setValue', '00');
			$('#fLaterMinute').combobox('setValue', '5');
			$('#fEarlierMinute').combobox('setValue', '5');
			$('#fAllowEarlierMinute').combobox('setValue', '60');
			$('#fAllowLaterMinute').combobox('setValue', '60');
			$('#fCheckedDays').combobox('setValue', '0.5');
			$("input[name=fAsLate]")[0].checked=true;
			$("input[name=fAsEarly]")[0].checked=true;
			$("input[class*=fWorkDay_checkbox][s=1]")[0].checked=true;
			$("input[class*=fWorkDay_checkbox][s=2]")[0].checked=true;
			$("input[class*=fWorkDay_checkbox][s=3]")[0].checked=true;
			$("input[class*=fWorkDay_checkbox][s=4]")[0].checked=true;
			$("input[class*=fWorkDay_checkbox][s=5]")[0].checked=true;
			$("input[class*=fWorkDay_checkbox][s=6]")[0].checked=true;
			$("input[class*=fWorkDay_checkbox][s=0]")[0].checked=true;
		}
		if("s"==o){
			$('#sCheckintime_hour').combobox('setValue', '13');
			$('#sCheckintime_minute').combobox('setValue', '30');
			$('#sCheckouttime_hour').combobox('setValue', '18');
			$('#sCheckouttime_minute').combobox('setValue', '00');
			$('#sLaterMinute').combobox('setValue', '5');
			$('#sEarlierMinute').combobox('setValue', '5');
			$('#sAllowEarlierMinute').combobox('setValue', '90');
			$('#sAllowLaterMinute').combobox('setValue', '120');
			$('#sCheckedDays').combobox('setValue', '0.5');
			$("input[name=sAsLate]")[0].checked=true;
			$("input[name=sAsEarly]")[0].checked=true;
			$("input[class*=sWorkDay_checkbox][s=1]")[0].checked=true;
			$("input[class*=sWorkDay_checkbox][s=2]")[0].checked=true;
			$("input[class*=sWorkDay_checkbox][s=3]")[0].checked=true;
			$("input[class*=sWorkDay_checkbox][s=4]")[0].checked=true;
			$("input[class*=sWorkDay_checkbox][s=5]")[0].checked=true;
			$("input[class*=sWorkDay_checkbox][s=6]")[0].checked=true;
			$("input[class*=sWorkDay_checkbox][s=0]")[0].checked=true;
		}
		if("t"==o){
			$('#tCheckintime_hour').combobox('setValue', '19');
			$('#tCheckintime_minute').combobox('setValue', '00');
			$('#tCheckouttime_hour').combobox('setValue', '22');
			$('#tCheckouttime_minute').combobox('setValue', '00');
			$('#tLaterMinute').combobox('setValue', '5');
			$('#tEarlierMinute').combobox('setValue', '5');
			$('#tAllowEarlierMinute').combobox('setValue', '60');
			$('#tAllowLaterMinute').combobox('setValue', '60');
			$('#tCheckedDays').combobox('setValue', '0.25');
			$("input[name=tAsLate]")[0].checked=true;
			$("input[name=tAsEarly]")[0].checked=true;
			$("input[class*=tWorkDay_checkbox][s=1]")[0].checked=true;
			$("input[class*=tWorkDay_checkbox][s=2]")[0].checked=true;
			$("input[class*=tWorkDay_checkbox][s=3]")[0].checked=true;
			$("input[class*=tWorkDay_checkbox][s=4]")[0].checked=true;
			$("input[class*=tWorkDay_checkbox][s=5]")[0].checked=true;
			$("input[class*=tWorkDay_checkbox][s=6]")[0].checked=true;
			$("input[class*=tWorkDay_checkbox][s=0]")[0].checked=true;
		}
		_refresh_checkSelect();
	}
	this.usetShift = function(o){
		if("f"==o){
			$('#fCheckintime_hour').combobox('setValue', '');
			$('#fCheckintime_minute').combobox('setValue', '');
			$('#fCheckouttime_hour').combobox('setValue', '');
			$('#fCheckouttime_minute').combobox('setValue', '');
			$('#fLaterMinute').combobox('setValue', '');
			$('#fEarlierMinute').combobox('setValue', '');
			$('#fAllowEarlierMinute').combobox('setValue', '');
			$('#fAllowLaterMinute').combobox('setValue', '');
			$('#fCheckedDays').combobox('setValue', '');
			$("input[name=fAsLate]")[0].checked=false;
			$("input[name=fAsEarly]")[0].checked=false;
			$("input[class*=fWorkDay_checkbox][s=1]")[0].checked=false;
			$("input[class*=fWorkDay_checkbox][s=2]")[0].checked=false;
			$("input[class*=fWorkDay_checkbox][s=3]")[0].checked=false;
			$("input[class*=fWorkDay_checkbox][s=4]")[0].checked=false;
			$("input[class*=fWorkDay_checkbox][s=5]")[0].checked=false;
			$("input[class*=fWorkDay_checkbox][s=6]")[0].checked=false;
			$("input[class*=fWorkDay_checkbox][s=0]")[0].checked=false;
		}
		if("s"==o){
			$('#sCheckintime_hour').combobox('setValue', '');
			$('#sCheckintime_minute').combobox('setValue', '');
			$('#sCheckouttime_hour').combobox('setValue', '');
			$('#sCheckouttime_minute').combobox('setValue', '');
			$('#sLaterMinute').combobox('setValue', '');
			$('#sEarlierMinute').combobox('setValue', '');
			$('#sAllowEarlierMinute').combobox('setValue', '');
			$('#sAllowLaterMinute').combobox('setValue', '');
			$('#sCheckedDays').combobox('setValue', '');
			$("input[name=sAsLate]")[0].checked=false;
			$("input[name=sAsEarly]")[0].checked=false;
			$("input[class*=sWorkDay_checkbox][s=1]")[0].checked=false;
			$("input[class*=sWorkDay_checkbox][s=2]")[0].checked=false;
			$("input[class*=sWorkDay_checkbox][s=3]")[0].checked=false;
			$("input[class*=sWorkDay_checkbox][s=4]")[0].checked=false;
			$("input[class*=sWorkDay_checkbox][s=5]")[0].checked=false;
			$("input[class*=sWorkDay_checkbox][s=6]")[0].checked=false;
			$("input[class*=sWorkDay_checkbox][s=0]")[0].checked=false;
		}
		if("t"==o){
			$('#tCheckintime_hour').combobox('setValue', '');
			$('#tCheckintime_minute').combobox('setValue', '');
			$('#tCheckouttime_hour').combobox('setValue', '');
			$('#tCheckouttime_minute').combobox('setValue', '');
			$('#tLaterMinute').combobox('setValue', '');
			$('#tEarlierMinute').combobox('setValue', '');
			$('#tAllowEarlierMinute').combobox('setValue', '');
			$('#tAllowLaterMinute').combobox('setValue', '');
			$('#tCheckedDays').combobox('setValue', '');
			$("input[name=tAsLate]")[0].checked=false;
			$("input[name=tAsEarly]")[0].checked=false;
			$("input[class*=tWorkDay_checkbox][s=1]")[0].checked=false;
			$("input[class*=tWorkDay_checkbox][s=2]")[0].checked=false;
			$("input[class*=tWorkDay_checkbox][s=3]")[0].checked=false;
			$("input[class*=tWorkDay_checkbox][s=4]")[0].checked=false;
			$("input[class*=tWorkDay_checkbox][s=5]")[0].checked=false;
			$("input[class*=tWorkDay_checkbox][s=6]")[0].checked=false;
			$("input[class*=tWorkDay_checkbox][s=0]")[0].checked=false;
		}
		_refresh_checkSelect();
	}
	
	//人员排班
	this.scheduleList = function() {
		XF.lightSideBar('scheduleList');
		_schedule_search(null,null,null);
	};
	this.addSchedule = function() {
		XF.lightSideBar('addSchedule');
		var url  = global.contextPath + "/check/addSchedule"
		$.ajax({
		  url: url,
		  type: "post",
		  data: {},
		  complete: function(xhr){
			  xhr = xhr['responseText'];
			  $("#checkCenter").html(xhr);
		  }
		});		
	};
	
	this.deleteSchedule = function(id) {
		$.messager.confirm('操作提示','确定删除这条记录吗',function(data){
			if(data){
				$.ajax({
					url:""+global.contextPath+"/check/deleteSchedule",
					type:"post",
					data:"id="+id,
					success:function(data){
						$.messager.show({
							title:'提示',
							msg:'删除成功',
							timeout:3000,
							showType:'slide'
						});
						XF.Check.scheduleListSearch();
					}
				});
			}
		});		
	}
	
	this.editSchedule = function(id) {
		$.ajax({
			type:'post',
			url:global.contextPath + "/check/editSchedule",
			data:{id:id},
			complete:function(xhr){
				xhr = xhr['responseText'];
				$('#checkCenter').html(xhr);
			}
		});
	}
	
	this.userSchedule = function(userid,username,scheduleid){
		$.ajax({
			type:'post',
			url:global.contextPath + "/check/userSchedule",
			data:{userid:userid,username:username,scheduleid:scheduleid},
			complete:function(xhr){
				xhr = xhr['responseText'];
				//$('#checkCenter').html(xhr);
				$("#schedule_popwin").html(xhr);
				$('#schedule_popwin').window('open');  
			}
		});
	}

	//人员管理
	this.userList = function(defaultSiteId) {
		var siteId = null;
		if(typeof(defaultSiteId)!='undefined'){
			siteId = defaultSiteId;
		}
		XF.lightSideBar('userList');
		_user_search(siteId,null,null,null);
	};
	
	this.userListSearch = function(){
		var userid = $("input[name=userid]").val();
		var username = $("input[name=username]").val();
		var siteid = $("#siteList").combobox('getValue');
		var deptid = $("#deptList").combobox('getValue');
		_user_search(siteid,deptid,userid,username);
	};
	
	this.editUser = function(userId){
		var url  = global.contextPath + "/check/editUser";
		var siteid = $("#siteList").combobox('getValue');
		$.ajax({
		  url: url,
		  type: "post",
		  data: {id:userId,siteid:siteid},
		  complete: function(xhr){
			  xhr = xhr['responseText'];
			  $("#checkCenter").html(xhr);
		  }
		});
	};
	
	//角色管理
	this.roleList = function(defaultSiteId) {
		var siteId = null;
		if(typeof(defaultSiteId)!='undefined'){
			siteId = defaultSiteId;
		}
		XF.lightSideBar('roleList');
		_role_search(siteId,null);
	};
	
	this.roleListSearch = function(){
		var siteid = $("#siteList").combobox('getValue');
		var rolename = $("input[name=rolename]").val();
		_role_search(siteid,rolename);
	};
	
	this.addRole = function(){
		XF.lightSideBar('addRole');
		var url  = global.contextPath + "/check/addRole"
		$.ajax({
		  url: url,
		  type: "post",
		  data: {},
		  complete: function(xhr){
			  xhr = xhr['responseText'];
			  $("#checkCenter").html(xhr);
		  }
		});
	};
	
	this.editRole = function(id) {
		$.ajax({
			type:'post',
			url:global.contextPath + "/check/editRole",
			data:{id:id},
			complete:function(xhr){
				xhr = xhr['responseText'];
				$('#checkCenter').html(xhr);
			}
		});
	};
	
	this.deleteRole = function(id) {
		$.messager.confirm('操作提示','确定删除这条记录吗',function(data){
			if(data){
				$.ajax({
					url:""+global.contextPath+"/check/doDeleteRole",
					type:"post",
					data:"id="+id,
					success:function(data){
						$.messager.show({
							title:'提示',
							msg:'删除成功',
							timeout:3000,
							showType:'slide'
						});
						XF.Check.roleListSearch();
					}
				});
			}
		});		
	};
	
	this.analyze = function() {
		XF.lightSideBar('analyze');
		var url  = global.contextPath + "/check/analyze"
		$.ajax({
		  url: url,
		  type: "post",
		  data: {},
		  complete: function(xhr){
			  xhr = xhr['responseText'];
			  $("#checkCenter").html(xhr);
		  }
		});		
	};
	
	//私有方法
	function _shift_search(siteid){
		config.shift_search['args'] = [siteid];
        SMT.xconfig.gvar.pageNum = '1';
        SMT.ajax(config.shift_search);
	}
	
	function _schedule_search(siteid,userid, deptid){
		config.schedule_search['args'] = [siteid,userid, deptid];
        SMT.xconfig.gvar.pageNum = '1';
        SMT.ajax(config.schedule_search);
	}
	
	this.scheduleListSearch = function() {
		var userid = $("input[name=userid]").val();
		var siteid = $("#siteList").combobox('getValue');
		var deptid = $("#deptList").combobox('getValue');
		_schedule_search(siteid,userid,deptid);
	}

	this.shiftListSearch = function() {
		var siteid = $("#siteList").combobox('getValue');
		_shift_search(siteid);
	}
	
   function _init_workDay_Select(){
	   var boxs = $(".fWorkDay_checkbox");
	   boxs.bind("click",function(e){
		   _refresh_checkSelect();
	   });
	   
	   var boxs2 = $(".sWorkDay_checkbox");
	   boxs2.bind("click",function(e){
		   _refresh_checkSelect();
	   });
	   
	   var boxs3 = $(".tWorkDay_checkbox");
	   boxs3.bind("click",function(e){
		   _refresh_checkSelect();
	   });
	   
   }
   
/*   function _init_schedule_workDay_Select(){
	   var boxs = $(".workDays_checkbox");
	   boxs.bind("click",function(e){
		   var v = "";
		   boxs.each(function(c){
			   if($(boxs[c]).is(':checked')){
				   var s = $(boxs[c]).attr("s");
				   v = v+s+",";
			   }
		   });
		   $("input[name=workDays]").val(v);
	   });
   }*/
   
   function _refresh_checkSelect(){
	   var boxs = $(".fWorkDay_checkbox");
	   var v1 = "";
	   boxs.each(function(c){
		   if($(boxs[c]).is(':checked')){
			   var s = $(boxs[c]).attr("s");
			   v1 = v1+s+",";
		   }
	   });
	   $("input[name=fWorkDay]").val(v1);
	   
	   var boxs2 = $(".sWorkDay_checkbox");
	   var v2 = "";
	   boxs2.each(function(c){
		   if($(boxs2[c]).is(':checked')){
			   var s = $(boxs2[c]).attr("s");
			   v2 = v2+s+",";
		   }
	   });
	   $("input[name=sWorkDay]").val(v2);
	   
	   var boxs3 = $(".tWorkDay_checkbox");
	   var v3 = "";
	   boxs3.each(function(c){
		   if($(boxs3[c]).is(':checked')){
			   var s = $(boxs3[c]).attr("s");
			   v3 = v3+s+",";
		   }
	   });
	   $("input[name=tWorkDay]").val(v3);
   }
   

	function _user_search(siteid,deptid,userid,username){
		config.user_search['args'] = [siteid,deptid,userid,username];
        SMT.xconfig.gvar.pageNum = '1';
        SMT.ajax(config.user_search);
	}
	function _role_search(siteid,rolename){
		config.role_search['args'] = [siteid,rolename];
        SMT.xconfig.gvar.pageNum = '1';
        SMT.ajax(config.role_search);
	}
	
	function _init_schedule(){
		$("select[name*=shiftid]").combobox({
			url:global.contextPath + '/check/shiftListBySiteId?siteid='+XF.Check.DefaultSiteId,
			valueField:'id',
			textField:'shiftName',
			onSelect:function(){
				//数据准备
				/*var json = $("#shiftid").combobox('getData');
				var jsonV = $("#shiftid").combobox('getValue');
				if(json.length>0){
					for(o in json){
						if(json[o].id==jsonV){
							_refreshShiftSelect(json[o]);
						}
					}
				}*/
			}
		});
	}
	
	function _refreshShiftSelect(shift){
		$(".tr_time_during").remove();
		var num = 0;
		if(typeof(shift.fCheckintime)!='undefined'&&shift.fCheckintime!=null&&shift.fCheckintime!=""){
			num++;
		}
		if(typeof(shift.sCheckintime)!='undefined'&&shift.sCheckintime!=null&&shift.sCheckintime!=""){
			num++;
		}
		if(typeof(shift.tCheckintime)!='undefined'&&shift.tCheckintime!=null&&shift.tCheckintime!=""){
			num++;
		}
		for(k=0;k<num;k++){
				//alert(json[o].shiftName);
				//准备数据
				var html = 
					"<tr class='tr_time_during'>" +
						"<td class='tdTitle'>第"+(k+1)+"时间段：</td>" +
						"<td class='' colspan='2'>" +
							"<div class='checkbox-wrap'>" +
								"<input type='hidden' name='workDays'>" +
								"<label>" +
									"<input type='checkbox' class='checkbox workDays_checkbox' s='1'>" +
									"<span>星期一</span>" +
								"</label>" +
								"<label>" +
									"<input type='checkbox' class='checkbox workDays_checkbox' s='2'>" +
									"<span>星期二</span>" +
								"</label>" +
								"<label>" +
									"<input type='checkbox' class='checkbox workDays_checkbox' s='3'>" +
									"<span>星期三</span>" +
								"</label>" +
								"<label>" +
									"<input type='checkbox' class='checkbox workDays_checkbox' s='4'>" +
									"<span>星期四</span>" +
								"</label>" +
								"<label>" +
									"<input type='checkbox' class='checkbox workDays_checkbox' s='5'>" +
									"<span>星期五</span>" +
								"</label>" +
								"<label>" +
									"<input type='checkbox' class='checkbox workDays_checkbox' s='6'>" +
									"<span>星期六</span>" +
								"</label>" +
								"<label>" +
									"<input type='checkbox' class='checkbox workDays_checkbox' s='7'>" +
									"<span>星期日</span>" +
								"</label>" +
							"</div>" +
						"</td>" +
				    "</tr>"; 
				$(".tr_time_during_next").before(html);
		}
	}
	
	this.reportList = function() {
		XF.lightSideBar('reportList');
		_report_search(null,null,null);
	};

	function _report_search(siteid, userid, deptid, startdate, enddate){
		config.report_search['args'] = [siteid, userid, deptid, startdate, enddate];
        SMT.xconfig.gvar.pageNum = '1';
        SMT.ajax(config.report_search);
	}
	
	this.reportListSearch = function() {
		var userid = $("input[name=userid]").val();
		var siteid = $("#siteList").combobox('getValue');
		var deptid = $("#deptList").combobox('getValue');
		var startdate = $("input[name=startdate]").val();
		var enddate = $("input[name=enddate]").val();
		_report_search(siteid,userid,deptid,startdate,enddate);
	}
	
	this.summaryList = function() {
		XF.lightSideBar('summaryList');
		_summary_search(null,null,null,null);
	};

	function _summary_search(siteid, userid, deptid, month){
		config.summary_search['args'] = [siteid, userid, deptid, month];
        SMT.xconfig.gvar.pageNum = '1';
        SMT.ajax(config.summary_search);
	}
	
	this.summaryListSearch = function() {
		var userid = $("input[name=userid]").val();
		var siteid = $("#siteList").combobox('getValue');
		var deptid = $("#deptList").combobox('getValue');
		var month = $("input[name=month]").val();
		_summary_search(siteid,userid,deptid,month);
	}

	this.submitAnalyzeForm = function() {
        var nodes = $('#users').tree('getChecked');
        var s = '';
        for(var i=0; i<nodes.length; i++){
        	if(nodes[i].id.match('D'))
        		continue;
            if (s != '') s += ',';
           	s += nodes[i].id;
        }
		var form = {
			userid: s,
			siteid: $("input[name=siteid]").val(),
			startdate: $("input[name=startdate]").val(),
			enddate: $("input[name=enddate]").val(),
			adduser: $("input[name=adduser]").val()
		};
		XF.hideError();
		$("#analyzeBtn").hide();
		$("#loading").show();
		$.ajax({
			type:'post',
			url:global.contextPath + "/check/doAnalyze",
			dataType: 'json',
			data:form,
			success:function(result){
				//$("#analyzeBtn").show();
				$("#complete").show();
				$("#loading").hide();
				if (result.status == 'SUCCESS') {
					$.messager.show({
						showType:'fade',
						msg:"操作成功",
						title:"提示",
						timeout:"1000"
					});
					//XF.Check.reportList();
				} else {
					XF.refreshAfterAddFaild(JSON.parse(result.errorJson));
				}
			}			
		});
	}
	
	this.addEmployee = function(){
		XF.lightSideBar('addEmployee');
		var url  = global.contextPath + "/check/addEmployee"
		$.ajax({
		  url: url,
		  type: "post",
		  data: {},
		  complete: function(xhr){
			  xhr = xhr['responseText'];
			  $("#checkCenter").html(xhr);
		  }
		});
	};
	
	this.submitAddEmployee = function() {
        var nodes = $('#users').tree('getChecked');
        var s = '';
        for(var i=0; i<nodes.length; i++){
        	if(nodes[i].id.match('D'))
        		continue;
        	if (nodes[i].id.length != 10)
        		continue;
            if (s != '') s += ',';
           	s += nodes[i].id+'_'+nodes[i].text;
        }
		var form = {
			userId: s,
			sn: $("#deviceList").combobox('getValue')
		};
		$.ajax({
			type:'post',
			url:global.contextPath + "/check/doAddEmployee",
			dataType: 'json',
			data:form,
			success:function(result){
				if (result.status == 'SUCCESS') {
					$.messager.show({
						showType:'fade',
						msg:"操作成功",
						title:"提示",
						timeout:"1000"
					});
					XF.Check.listEmployee();
				} else {
					$.messager.show({
						title:'提示',
						msg:'添加失败:'+result.msg,
						timeout:5000,
						showType:'slide'
					  });
				}
			}			
		});
	};
	
	this.listEmployee = function(){
		XF.lightSideBar('listEmployee');
		_search_listEmployee(null,null);
	};
	
	this.listEmployeeSearch = function(){
		var sn = $("input[name=sn]").val();
		var userid = $("input[name=userid]").val();
		_search_listEmployee(sn,userid);
	};
	
	function _search_listEmployee(sn,userid){
    	config.employee_search['args'] = [sn,userid];
    	SMT.xconfig.gvar.pageNum = '1';
    	SMT.ajax(config.employee_search);
	}
	
	this.deleteEmployee = function(id) {
		$.messager.confirm('操作提示','确定删除这条记录吗',function(data){
			if(data){
				$.ajax({
					url:""+global.contextPath+"/check/deleteEmployee",
					type:"post",
					data:"id="+id,
					success:function(data){
						$.messager.show({
							title:'提示',
							msg:'删除成功',
							timeout:3000,
							showType:'slide'
						});
						XF.Check.listEmployeeSearch();
					}
				});
			}
		});		
	};
	
	this.dataSummaryList = function() {
		XF.lightSideBar('dataSummaryList');
		_datasummary_search(null,null,null,null,null,null);
	};
	
	this.dataSummaryListSearch = function() {
		var userid = $("input[name=userid]").val();
		var siteid = $("#siteList").combobox('getValue');
		var deptid = $("#deptList").combobox('getValue');
		var startdate = $("input[name=startdate]").val();
		var enddate = $("input[name=enddate]").val();
		var deviceid = $("#deviceList").combobox('getValue');
		_datasummary_search(siteid,userid,deptid,startdate,enddate,deviceid);
	}

	function _datasummary_search(siteid, userid, deptid,startdate,enddate,deviceid){
		config.datasummary_search['args'] = [siteid, userid, deptid,startdate,enddate,deviceid];
        SMT.xconfig.gvar.pageNum = '1';
        SMT.ajax(config.datasummary_search);
	}
	
	this.userDetail = function(userid){
		var startdate = $("input[name=startdate]").val();
		var enddate = $("input[name=enddate]").val();
		var deviceid = $("#deviceList").combobox('getValue');
		$.ajax({
			type:'post',
			url:global.contextPath + "/check/dataUserList",
			data:{userid:userid,deviceid:deviceid,startdate:startdate,enddate:enddate},
			complete:function(xhr){
				xhr = xhr['responseText'];
				//$('#checkCenter').html(xhr);
				$("#userdetail_popwin").html(xhr);
				$('#userdetail_popwin').window('open');  
			}
		});
	}
	
}();

config.leave_search = {
		url: ""+global.contextPath+"/check/leaveList",
	    argsOrder: ['year_month','siteid','userid','deptid'],
	    needVar: true,
	    replaceExp: '#checkCenter',
	    callBack: function() {
	    }		
	};

config.leave_person_search = {
		url: ""+global.contextPath+"/check/leavePersonList",
	    argsOrder: ['year_month','siteid','userid','deptid'],
	    needVar: true,
	    replaceExp: '#checkCenter',
	    callBack: function() {
	    }		
	};

config.shift_search = {
		url: ""+global.contextPath+"/check/shiftList",
	    argsOrder: ['siteid'],
	    needVar: true,
	    replaceExp: '#checkCenter',
	    callBack: function() {
	    }		
	};
config.schedule_search = {
		url: ""+global.contextPath+"/check/scheduleList",
	    argsOrder: ['siteid','userid','deptid'],
	    needVar: true,
	    replaceExp: '#checkCenter',
	    callBack: function() {
	    }		
	};
config.mend_search = {
	url: ""+global.contextPath+"/check/mendList",
    argsOrder: ['year_month','siteid','userid','deptid'],
    needVar: true,
    replaceExp: '#checkCenter',
    callBack: function() {
    }		
};
config.mend_person_search = {
		url: ""+global.contextPath+"/check/mendPersonList",
	    argsOrder: ['year_month','siteid','userid','deptid'],
	    needVar: true,
	    replaceExp: '#checkCenter',
	    callBack: function() {
	    }		
	};
config.holiday_search = {
		url: ""+global.contextPath+"/check/holidayList",
	    argsOrder: ['siteid'],
	    needVar: true,
	    replaceExp: '#checkCenter',
	    callBack: function() {
	    }		
	};
config.data_search = {
		url: ""+global.contextPath+"/check/dataList",
	    argsOrder: ['year_month','siteid','deptid','userid'],
	    needVar: true,
	    replaceExp: '#checkCenter',
	    callBack: function() {
	    }		
	};
config.checkDatailReportList_search = {
		url: ""+global.contextPath+"/check/checkDatailReportList",
	    argsOrder: ['year_month','siteid','deptid','userid'],
	    needVar: true,
	    replaceExp: '#checkCenter',
	    callBack: function() {
	    }		
	};
config.checkSitesReportList_search = {
		url: ""+global.contextPath+"/check/checkSitesReportList",
	    argsOrder: ['siteid','year_month'],
	    needVar: true,
	    replaceExp: '#checkCenter',
	    callBack: function() {
	    }		
	};
config.user_search = {
		url: ""+global.contextPath+"/check/userList",
	    argsOrder: ['siteid','deptid','userid','username'],
	    needVar: true,
	    replaceExp: '#checkCenter',
	    callBack: function() {
	    }		
	};
config.role_search = {
		url: ""+global.contextPath+"/check/roleList",
	    argsOrder: ['siteid','rolename'],
	    needVar: true,
	    replaceExp: '#checkCenter',
	    callBack: function() {
	    }		
	};
config.report_search = {
		url: ""+global.contextPath+"/check/totalReportList",
	    argsOrder: ['siteid','userid','deptid','startdate','enddate'],
	    needVar: true,
	    replaceExp: '#checkCenter',
	    callBack: function() {
	    }		
	};
config.summary_search = {
		url: ""+global.contextPath+"/check/summaryList",
	    argsOrder: ['siteid','userid','deptid','month'],
	    needVar: true,
	    replaceExp: '#checkCenter',
	    callBack: function() {
	    }		
	};


config.employee_search = {
		url: ""+global.contextPath+"/check/employeeList/",
	    argsOrder: ['sn','userId'],
	    needVar: true,
	    replaceExp: '#checkCenter',
	    callBack: function() {
	    }		
	};

config.datasummary_search = {
		url: ""+global.contextPath+"/check/dataSummaryList",
	    argsOrder: ['siteid','userid','deptid','startdate','enddate','deviceid'],
	    needVar: true,
	    replaceExp: '#checkCenter',
	    callBack: function() {
	    }		
	};
//config.datasummary_search = {
//		url: ""+global.contextPath+"/check/checkDatailReportList",
//	    argsOrder: ['siteid','userid','deptid','startdate','enddate','deviceid'],
//	    needVar: true,
//	    replaceExp: '#checkCenter',
//	    callBack: function() {
//	    }		
//	};
